package com.seari.custody.service.Impl;

import com.google.api.client.util.ArrayMap;
import com.seari.custody.mapper.StatisticsProjectMapper;
import com.seari.custody.service.StatisticsProjectService;
import com.seari.custody.util.Common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("StatisticsProjectService")
@Transactional(rollbackFor = Exception.class)
public class StatisticsProjectServiceImpl implements StatisticsProjectService {

    //月份
    @Value("${month}")
    private String month;

    //运营状态
    @Value("${projectOperation}")
    private String projectOperation;

    //阶段统计
    @Value("${phaseStatistics}")
    private String phaseStatistics;

    //线路情况
    @Value("${subwayRoute}")
    private String subwayRoute;

    //类型
    @Value("${itemClassification}")
    private String itemClassification;

    //区划
    @Value("${compartment}")
    private String compartment;

    //审核工作统计
    @Value("${statisticalWork}")
    private String statisticalWork;

    //项目参与情况
    @Value("${participants}")
    private String participants;

    @Autowired
    private StatisticsProjectMapper statisticsProjectMapper;

    @Override
    public List<Map<String, Object>> saverDivision(Map<String, String> map) throws Exception {
        String type = map.get("type");
        String agenda = map.get("agenda");
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String[] typeRegionalism = {};
        // 类型
        switch (type) {
            //监护大纲
            case "1":
                typeRegionalism = "1".split(",");
                break;
            //技审意见许可类
            case "2":
                typeRegionalism = "5".split(",");
                break;
            //技审意见征询类
            case "3":
                typeRegionalism = "1,2,3,4".split(",");
                break;
        }
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("typeRegionalism", typeRegionalism);
        //技审意见|专项保护方案
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        pending2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s2 = statisticsProjectMapper.saverDivision(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        finish1.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s3 = statisticsProjectMapper.saverDivision(finish1);
        //技审意见(征询)
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        finish2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s4 = statisticsProjectMapper.saverDivision(finish2);
        //技审意见（许可）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        finish3.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s5 = statisticsProjectMapper.saverDivision(finish3);
        List<Map<String, Object>> fileContenteded = Common.cutting1(compartment);
        List<Map<String, String>> total = new ArrayList<>();
        switch (agenda) {
            case "1":
                total.addAll(s1);
                total.addAll(s2);
                break;
            case "2":
                total.addAll(s3);
                total.addAll(s4);
                total.addAll(s5);
                break;
        }

        for (int i = 0; i < total.size(); i++) {
            String project_addr = total.get(i).get("project_addr");
            for (int j = 0; j < fileContenteded.size(); j++) {
                String name = (String) fileContenteded.get(j).get("name");
                Integer value = (Integer) fileContenteded.get(j).get("value");
                if (project_addr.contains(name)) {
                    int value1 = value + 1;
                    fileContenteded.get(j).put("value", value1);
                }
            }
        }

        return fileContenteded;
    }

    @Override
    public Map<String, Object> saverline(Map<String, String> map) throws Exception {
        String type = map.get("type");
        String agenda = map.get("agenda");
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String[] typeRegionalism = {};
        // 类型
        switch (type) {
            //监护大纲
            case "1":
                typeRegionalism = "1".split(",");
                break;
            //技审意见许可类
            case "2":
                typeRegionalism = "5".split(",");
                break;
            //技审意见征询类
            case "3":
                typeRegionalism = "1,2,3,4".split(",");
                break;
        }
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("typeRegionalism", typeRegionalism);
        //技审意见|专项保护方案
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        pending2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s2 = statisticsProjectMapper.saverDivision(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        finish1.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s3 = statisticsProjectMapper.saverDivision(finish1);
        //技审意见(征询)
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        finish2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s4 = statisticsProjectMapper.saverDivision(finish2);
        //技审意见（许可）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        finish3.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s5 = statisticsProjectMapper.saverDivision(finish3);
        List fileContenteded = Common.cutting2(subwayRoute);
        List<Map<String, String>> total = new ArrayList<>();

        switch (agenda) {
            case "1":
                total.addAll(s1);
                total.addAll(s2);
                break;
            case "2":
                total.addAll(s3);
                total.addAll(s4);
                total.addAll(s5);
                break;
        }

        List list = new ArrayList();
        List list1 = new ArrayList();
        for (int i = 0; i < total.size(); i++) {
            String metro_relation = total.get(i).get("metro_relation");
            List postfix = Common.getNumberInString(metro_relation);
            list.addAll(postfix);
        }
        for (int i = 0; i < fileContenteded.size(); i++) {
            String route = String.valueOf(fileContenteded.get(i));
            int sum = 0;
            for (int m = 0; m < list.size(); m++) {
                String o = list.get(m).toString();
                if (route.contains(o)) {
                    sum = sum + 1;
                }
            }
            list1.add(sum);
        }
        Map<String, Object> made = new HashMap<>();
        made.put("name", fileContenteded);
        made.put("value", list1);
        return made;
    }

    @Override
    public Map<String, Object> saverMonth(Map<String, String> map) throws Exception {


        String type = map.get("type");
        String agenda = map.get("agenda");
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String[] typeRegionalism = {};
        // 类型
        switch (type) {
            //监护大纲
            case "1":
                typeRegionalism = "1".split(",");
                break;
            //技审意见许可类
            case "2":
                typeRegionalism = "5".split(",");
                break;
            //技审意见征询类
            case "3":
                typeRegionalism = "1,2,3,4".split(",");
                break;
        }
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("typeRegionalism", typeRegionalism);
        //技审意见|专项保护方案
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        pending2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s2 = statisticsProjectMapper.saverDivision(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        finish1.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s3 = statisticsProjectMapper.saverDivision(finish1);
        //技审意见(征询)
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        finish2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s4 = statisticsProjectMapper.saverDivision(finish2);
        //技审意见（许可）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        finish3.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s5 = statisticsProjectMapper.saverDivision(finish3);
        List<String> fileContenteded = Common.cutting2(month);
        List<Map<String, String>> total = new ArrayList<>();

        switch (agenda) {
            case "1":
                total.addAll(s1);
                total.addAll(s2);
                break;
            case "2":
                total.addAll(s3);
                total.addAll(s4);
                total.addAll(s5);
                break;
        }

        List list = new ArrayList();
        List list1 = new ArrayList();
        for (int i = 0; i < total.size(); i++) {
            String month = total.get(i).get("month");
            List postfix = Common.getNumberInString(month);
            list.addAll(postfix);
        }
        for (int i = 0; i < fileContenteded.size(); i++) {
            String route = fileContenteded.get(i);
            String numeric = Common.getNumeric(route);
            int sum = 0;
            for (int m = 0; m < list.size(); m++) {
                String o = list.get(m).toString();
                if (numeric.equals(o)) {
                    sum = sum + 1;
                }
            }
            list1.add(sum);
        }
        Map<String, Object> made = new HashMap<>();
        made.put("name", fileContenteded);
        made.put("value", list1);
        return made;
    }

    @Override
    public List<Map<String, Object>> projectApplication(Map<String, String> map) throws Exception {

        String type = map.get("type");
        String agenda = map.get("agenda");
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String[] typeRegionalism = {};
        // 类型
        switch (type) {
            //监护大纲
            case "1":
                typeRegionalism = "1".split(",");
                break;
            //技审意见许可类
            case "2":
                typeRegionalism = "5".split(",");
                break;
            //技审意见征询类
            case "3":
                typeRegionalism = "1,2,3,4".split(",");
                break;
        }
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("typeRegionalism", typeRegionalism);
        //技审意见|专项保护方案
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        pending2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s2 = statisticsProjectMapper.saverDivision(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        finish1.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s3 = statisticsProjectMapper.saverDivision(finish1);
        //技审意见(征询)
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        finish2.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s4 = statisticsProjectMapper.saverDivision(finish2);
        //技审意见（许可）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        finish3.put("typeRegionalism", typeRegionalism);
        List<Map<String, String>> s5 = statisticsProjectMapper.saverDivision(finish3);
        List<Map<String, String>> map1 = new ArrayList<>();
        List<Map<String, String>> map2 = new ArrayList<>();
        switch (agenda) {
            case "1":
                //监护大纲
                map1.addAll(s1);
                //技审意见|专项保护方案
                map2.addAll(s2);
                break;
            case "2":
                map2.addAll(s3);
                map2.addAll(s4);
                map2.addAll(s5);
                break;
        }


        //监护大纲
        List list3 = new ArrayList();
        for (int m = 0; m < map1.size(); m++) {
            String uuid = map1.get(m).get("uuid");
            String s = statisticsProjectMapper.saverOutline(uuid);
            if (s == null) {
                list3.add("0");
            } else {
                list3.add(s);
            }
        }
        //技审意见(许可|征询)
        List list1 = new ArrayList();
        for (int m = 0; m < map2.size(); m++) {
            String uuid = map2.get(m).get("uuid");
            String s = statisticsProjectMapper.saverReview(uuid);
            if (s == null) {
                list1.add("0");
            } else {
                list1.add(s);
            }
        }


        List<Map<String, Object>> fileContenteded = Common.cutting1(itemClassification);
        // 技审意见（征询、许可类）
        for (int i = 0; i < list1.size(); i++) {
            String typeNum = list1.get(i).toString();
            for (int m = 0; m < fileContenteded.size(); m++) {
                String name = (String) fileContenteded.get(m).get("name");
                Integer value = (Integer) fileContenteded.get(m).get("value");
                if (name.equals("基坑类") && typeNum.equals("1")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("拆除类") && typeNum.equals("2")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("勘探类") && typeNum.equals("3")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("绿化类") && typeNum.equals("4")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("市政类") && typeNum.equals("5")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("穿越类") && typeNum.equals("6")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("建筑类") && typeNum.equals("7")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                }
            }
        }

        //监护大纲
        for (int i = 0; i < list3.size(); i++) {
            String typeNum = list3.get(i).toString();
            for (int m = 0; m < fileContenteded.size(); m++) {
                String name = (String) fileContenteded.get(m).get("name");
                Integer value = (Integer) fileContenteded.get(m).get("value");
                if (name.equals("基坑类") && typeNum.equals("1")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("穿越类") && typeNum.equals("2")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("加卸载、管线、桥梁、桩基及其他") && typeNum.equals("3")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                }
            }
        }

        return fileContenteded;
    }

    @Override
    public Map<String, Object> saverProject(Map<String, String> map) throws Exception {
        Map<String, Object> map1 = new ArrayMap<>();
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        Map<String, Object> details = new HashMap<>();
        details.put("startDate", startDate);
        details.put("dateClosed", dateClosed);
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        //技审意见|专项保护方案
        Integer s = statisticsProjectMapper.projectQueryTerm(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        Integer s1 = statisticsProjectMapper.projectQueryTerm(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        Integer s2 = statisticsProjectMapper.projectQueryTerm(finish1);
        //技审意见（许可）|专项保护方案
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        Integer s3 = statisticsProjectMapper.projectQueryTerm(finish2);
        //技审意见（征询）|专项保护方案
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        Integer s4 = statisticsProjectMapper.projectQueryTerm(finish3);

        //项目总数——处理中
        map1.put("rojectsProcessingNumber", s + s1);
        //项目总数——已完结
        map1.put("rojectsFinishNumber", s2 + s3 + s4);
        //项目总数
        List<Map<String, String>> map2 = statisticsProjectMapper.saverDivision(details);


        map1.put("rojectsNumber", map2.size());
        //生成《监护大纲技术要求表》
        Integer integer5 = statisticsProjectMapper.monitoringOutline("'1','2','3','4','7'", startDate, dateClosed);
        map1.put("createTutelageNumber", integer5);
        //审核《监护大纲》
        Integer integer6 = statisticsProjectMapper.monitoringOutline("'5','6'", startDate, dateClosed);
        map1.put("uploadTutelageNumber", integer6);
        //生成《技审意见》
        Integer integer1 = statisticsProjectMapper.reviewIndex("0", startDate, dateClosed);
        map1.put("createReviewNumber", integer1);
        //上传《技审意见(草稿)》
        Integer integer2 = statisticsProjectMapper.reviewIndex("1", startDate, dateClosed);
        map1.put("uploadingReviewNumber", integer2);
        //生成《专项保护方案模板》
        Integer integer3 = statisticsProjectMapper.reviewIndex("0", startDate, dateClosed);
        map1.put("createProgramNumber", integer3);
        //审核《专项保护方案》
        Integer integer4 = statisticsProjectMapper.reviewIndex("1", startDate, dateClosed);
        map1.put("uploadProgramNumber", integer4);
        return map1;
    }

    @Override
    public List<Map<String, Object>> phaseStatistics(Map<String, String> map) throws Exception {
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String type = map.get("agenda");

        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        //技审意见|专项保护方案
        List<Map<String, Object>> s1 = statisticsProjectMapper.phaseStatistics(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        List<Map<String, Object>> s2 = statisticsProjectMapper.phaseStatistics(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        List<Map<String, Object>> s3 = statisticsProjectMapper.phaseStatistics(finish1);
        //技审意见(许可)
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        List<Map<String, Object>> s4 = statisticsProjectMapper.phaseStatistics(finish2);
        //技审意见（征询）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        List<Map<String, Object>> s5 = statisticsProjectMapper.projectOperation(finish3);
        List<Map<String, Object>> fileContenteded = Common.cutting1(phaseStatistics);
        List<Map<String, Object>> total = new ArrayList<>();
        switch (type) {
            //待处理
            case "1":
                total.addAll(s1);
                total.addAll(s2);
                break;
            //已完结
            case "2":
                total.addAll(s3);
                total.addAll(s4);
                total.addAll(s5);
                break;
        }
        for (int i = 0; i < total.size(); i++) {
            String typeNum = total.get(i).get("type").toString();
            for (int m = 0; m < fileContenteded.size(); m++) {
                String name = (String) fileContenteded.get(m).get("name");
                Integer value = (Integer) fileContenteded.get(m).get("value");
                if (name.equals("立项阶段") && typeNum.equals("1")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("可研阶段") && typeNum.equals("2")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("方案阶段") && typeNum.equals("3")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("初步设计阶段") && typeNum.equals("4")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("施工图阶段") && typeNum.equals("5")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("结合改造") && typeNum.equals("6")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                }
            }
        }
        return fileContenteded;
    }

    @Override
    public List<Map<String, Object>> projectOperation(Map<String, String> map) throws Exception {
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String agenda = map.get("agenda");
        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        //技审意见|专项保护方案
        List<Map<String, Object>> s1 = statisticsProjectMapper.projectOperation(pending1);
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        List<Map<String, Object>> s2 = statisticsProjectMapper.projectOperation(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        List<Map<String, Object>> s3 = statisticsProjectMapper.projectOperation(finish1);
        //技审意见（许可）
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("typeRegionalism", "5".split(","));
        finish2.put("flowStatus", "9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        List<Map<String, Object>> s4 = statisticsProjectMapper.projectOperation(finish2);
        //技审意见（征询）
        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("typeRegionalism", "1,2,3,4".split(","));
        finish3.put("flowStatus", "6".split(","));
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        List<Map<String, Object>> s5 = statisticsProjectMapper.projectOperation(finish3);


        List<Map<String, Object>> fileContenteded = Common.cutting1(projectOperation);
        List<Map<String, Object>> total = new ArrayList<>();
        switch (agenda) {
            case "1":
                total.addAll(s1);
                total.addAll(s2);
                break;
            case "2":
                total.addAll(s3);
                total.addAll(s4);
                total.addAll(s5);
                break;
        }

        for (int i = 0; i < total.size(); i++) {
            String typeNum = total.get(i).get("line_type").toString();
            for (int m = 0; m < fileContenteded.size(); m++) {
                String name = (String) fileContenteded.get(m).get("name");
                Integer value = (Integer) fileContenteded.get(m).get("value");
                if (name.equals("运营") && typeNum.equals("1")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("在建") && typeNum.equals("2")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("规划") && typeNum.equals("3")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                } else if (name.equals("其他") && typeNum.equals("0")) {
                    int value1 = value + 1;
                    fileContenteded.get(m).put("value", value1);
                }

            }
        }
        return fileContenteded;
    }

    @Override
    public Map<String, Object> projectTask(Map<String, String> map) throws Exception {
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String name = map.get("name");
        Map<String, Object> pending1 = new ArrayMap<>();
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("name", name);
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        Map<String, Object> map1 = new HashMap<>();
        map1.put("sum", s1.size());
        return map1;
    }

    @Override
    public List<Map<String, Object>> statisticalWork(Map<String, String> map) throws Exception {
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String name = map.get("name");
        Map<String, Object> pending1 = new ArrayMap<>();
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("name", name);
        List<Map<String, String>> s1 = statisticsProjectMapper.saverDivision(pending1);
        List list = new ArrayList();
        for (int i = 0; i < s1.size(); i++) {
            String uuid = s1.get(i).get("uuid");
            list.add(uuid);
        }
        Map<String, Object> saverTechnica = new HashMap<>();
        saverTechnica.put("uploadingId", "1");
        saverTechnica.put("fileUuid", list);
        Integer integer = statisticsProjectMapper.saverTechnicalGive(saverTechnica);
        saverTechnica.put("usersUpload", "1");
        Integer integer1 = statisticsProjectMapper.saverSpecialGive(saverTechnica);

        Integer integer2 = statisticsProjectMapper.monitoringTheOutlineGive(list);
        List<Integer> total = new ArrayList();
        total.add(integer);
        total.add(integer1);
        total.add(integer2);
        List<Map<String, Object>> fileContenteded = Common.cutting1(statisticalWork);
        for (int m = 0; m < fileContenteded.size(); m++) {
            Integer num = total.get(m);
            //个人个数
            fileContenteded.get(m).put("value", num);
            //
        }
        return fileContenteded;
    }

    @Override
    public List<Map<String, Object>> projectParticipants(Map<String, String> map) throws Exception {
        // 总项目数   个人处理中项目
        String startDate = map.get("startDate");
        String dateClosed = map.get("dateClosed");
        String name = map.get("name");

        //待处理
        Map<String, Object> pending1 = new ArrayMap<>();
        //监护大纲
        pending1.put("outlineExist", "1");
        pending1.put("outlineStatus", "1,2,3,4,5,6".split(","));
        pending1.put("startDate", startDate);
        pending1.put("dateClosed", dateClosed);
        pending1.put("managerNumber", name);
        Integer s = statisticsProjectMapper.projectQueryTerm(pending1);
        //技审意见|专项保护方案
        Map<String, Object> pending2 = new ArrayMap<>();
        pending2.put("flowStatus", "1,2,3,4,5,7,8".split(","));
        pending2.put("startDate", startDate);
        pending2.put("dateClosed", dateClosed);
        pending2.put("managerNumber", name);
        Integer s1 = statisticsProjectMapper.projectQueryTerm(pending2);
        //已完结
        Map<String, Object> finish1 = new ArrayMap<>();
        //监护大纲
        finish1.put("outlineExist", "1");
        finish1.put("outlineStatus", "7".split(","));
        finish1.put("startDate", startDate);
        finish1.put("dateClosed", dateClosed);
        finish1.put("managerNumber", name);
        Integer s2 = statisticsProjectMapper.projectQueryTerm(finish1);
        //技审意见|专项保护方案
        Map<String, Object> finish2 = new ArrayMap<>();
        finish2.put("flowStatus", "6,9".split(","));
        finish2.put("startDate", startDate);
        finish2.put("dateClosed", dateClosed);
        finish2.put("managerNumber", name);
        Integer s3 = statisticsProjectMapper.projectQueryTerm(finish2);

        Map<String, Object> finish3 = new ArrayMap<>();
        finish3.put("managerNumber", name);
        finish3.put("startDate", startDate);
        finish3.put("dateClosed", dateClosed);
        //会议总数
        List<Map<String, String>> s4 = statisticsProjectMapper.saverDivision(finish3);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < s4.size(); i++) {
            String uuid = s4.get(i).get("uuid").toString();
            list.add(uuid);
        }
        Map<String, Object> meeting = new HashMap<>();
        Integer meetingNumer1 = statisticsProjectMapper.salesMeeting(meeting);
        Integer meetingNumer2 = 0;
        if (list.size() == 0) {
            meetingNumer2 = 0;
        } else {
            meeting.put("meetingId", list);
            meetingNumer2 = statisticsProjectMapper.salesMeeting(meeting);
        }
        //会议总数
        //个人会议数目
        List<Map<String, Object>> fileContenteded = Common.cutting1(participants);
        List<Integer> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        List<Integer> list3 = new ArrayList<>();
        //个数——待处理|已完结
        list1.add(s + s1);
        list1.add(s2 + s3);
        list1.add(meetingNumer2);
        //百分比
        int sum = s + s1 + s2 + s3;
        NumberFormat fmt = NumberFormat.getPercentInstance();
        int sumzj = sum == 0 ? 1 : sum;   //三目运算符避免除0异常
        list2.add(fmt.format((float) (s + s1) / sumzj));
        list2.add(fmt.format((float) (s2 + s3) / sumzj));
        list2.add(fmt.format((float) (meetingNumer2) / meetingNumer1));
        //总数
        list3.add(s + s1 + s2 + s3);
        list3.add(s + s1 + s2 + s3);
        list3.add(meetingNumer1);
        for (int i = 0; i < fileContenteded.size(); i++) {
            fileContenteded.get(i).put("value", list1.get(i));
            fileContenteded.get(i).put("sum", list3.get(i));
            fileContenteded.get(i).put("percentage", list2.get(i));
        }
        //个人已完结项目数
        return fileContenteded;
    }


}
